/**
 * DownloadFile.java
 */
package dataTypes;

/**
 * This class contains additionally (to class File) information about file state
 * @author Michal Kolodziejski
 *
 */
public class DownloadFile extends File {

    public enum DownloadStateType {

        WAITING {

            @Override
            public String toString() {
                return "Waiting";
            }
        },
        ACTIVE {

            @Override
            public String toString() {
                return "Active";
            }
        },
        STOPPED {

            @Override
            public String toString() {
                return "Stopped";
            }
        },
        WAITING_FOR_HOSTS {

            @Override
            public String toString() {
                return "Waiting for host";
            }
        }
    }
    private DownloadStateType downloadState;
    protected int downloadedPartsNumber;

    public DownloadFile() {
        downloadedPartsNumber = 0;
    }

    public DownloadFile(DownloadFile df) {
        super(df);
        this.downloadState = df.downloadState;
        this.downloadedPartsNumber = df.downloadedPartsNumber;
    }

    public DownloadFile(String path, long size, String hash, DownloadStateType downloadState, int downloadedPartsNumber) {
        super(path, size, hash);
        this.downloadState = downloadState;
        this.downloadedPartsNumber = downloadedPartsNumber;
    }

    /**
     * @return the downloadState
     */
    public DownloadStateType getDownloadState() {
        return downloadState;
    }

    /**
     * @param downloadState the downloadState to set
     */
    public void setDownloadState(DownloadStateType downloadState) {
        this.downloadState = downloadState;
    }

    @Override
    public String toString() {
        StringBuilder toStringBuilder = new StringBuilder();
        toStringBuilder.append(super.toString());
        toStringBuilder.append("\n");
        toStringBuilder.append("\ndownloadState: ");
        toStringBuilder.append(downloadState);
        return toStringBuilder.toString();
    }

    /**
     * @return the downloadedPartsNumber
     */
    public int getDownloadedPartsNumber() {
        return downloadedPartsNumber;

    }

    /**
     * Setter
     * @param downloadedPartsNumber the downloadedPartsNumber
     */
    public void setDownloadedPartsNumber(int downloadedPartsNumber) {
        this.downloadedPartsNumber = downloadedPartsNumber;
    }
}
